home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / WindowDrawEditor.cpp < prev    next >
Text File  |  1997-02-20  |  5KB  |  160 lines

  1. /*
  2.  *  File:       WindowDrawEditor.h
  3.  *  Summary:       A view that knows how to edit a TWindow's drawing info.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->    12/24/96    JDJ        Created
  12.  */
  13.  
  14. #include "WindowDrawEditor.h"
  15.  
  16. #include <ZColorSwatch.h>
  17. #include <ZControl.h>
  18. #include <ZTextBox.h>
  19.  
  20.  
  21. // ===================================================================================
  22. //    class CEditWindowDrawCommand
  23. // ===================================================================================
  24.  
  25. //---------------------------------------------------------------
  26. //
  27. // CEditWindowDrawCommand::~CEditWindowDrawCommand
  28. //
  29. //---------------------------------------------------------------
  30. CEditWindowDrawCommand::~CEditWindowDrawCommand()
  31. {
  32. }
  33.  
  34.  
  35. //---------------------------------------------------------------
  36. //
  37. // CEditWindowDrawCommand::CEditWindowDrawCommand
  38. //
  39. //---------------------------------------------------------------
  40. CEditWindowDrawCommand::CEditWindowDrawCommand(TWindow* pane, const SWindowInfo& oldInfo, const SWindowInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  41. {
  42. }
  43.  
  44.  
  45. //---------------------------------------------------------------
  46. //
  47. // CEditWindowDrawCommand::UpdatePane
  48. //
  49. //---------------------------------------------------------------
  50. void CEditWindowDrawCommand::UpdatePane(const SWindowInfo& newInfo)
  51. {
  52.     SWindowInfo info = mPane->GetInfo();
  53.     
  54.     info.attr.showNew          = newInfo.attr.showNew;
  55.     info.attr.startOnPreferred = newInfo.attr.startOnPreferred;
  56.     info.attr.autoPosition     = newInfo.attr.autoPosition;
  57.     info.attr.eraseOnUpdate    = newInfo.attr.eraseOnUpdate;
  58.     info.attr.color            = newInfo.attr.color;
  59.  
  60.     mPane->SetInfo(info);
  61. }
  62.  
  63. #pragma mark -
  64.  
  65. // ===================================================================================
  66. //    CWindowDrawEditor
  67. // ===================================================================================
  68.  
  69. static TReanimatorRegister<CWindowDrawEditor> sWindowDrawEditorRegistrar;
  70.  
  71. //---------------------------------------------------------------
  72. //
  73. // CWindowDrawEditor::~CWindowDrawEditor
  74. //
  75. //---------------------------------------------------------------
  76. CWindowDrawEditor::~CWindowDrawEditor()
  77. {
  78. }
  79.  
  80.  
  81. //---------------------------------------------------------------
  82. //
  83. // CWindowDrawEditor::CWindowDrawEditor
  84. //
  85. //---------------------------------------------------------------
  86. CWindowDrawEditor::CWindowDrawEditor(TView* superView) : Inherited(superView)
  87. {
  88. }
  89.  
  90.  
  91. //---------------------------------------------------------------
  92. //
  93. // CWindowDrawEditor::Create                            [static]
  94. //
  95. //---------------------------------------------------------------
  96. MReanimatable* CWindowDrawEditor::Create(MReanimatable* parent)
  97. {
  98.     return new CWindowDrawEditor(dynamic_cast<TView*>(parent));
  99. }
  100.  
  101.  
  102. //---------------------------------------------------------------
  103. //
  104. // CWindowDrawEditor::GetEditorInfo        
  105. //
  106. //---------------------------------------------------------------
  107. SWindowInfo CWindowDrawEditor::GetEditorInfo() const
  108. {
  109.     SWindowInfo info;
  110.     
  111.     TControl* control = nil;
  112.     TColorSwatch* swatch = nil;
  113.         
  114.     control = dynamic_cast<TControl*>(this->FindSubPane("Position"));
  115.     info.attr.autoPosition = (EAutoPosition) control->GetValue();
  116.     
  117.     control = dynamic_cast<TControl*>(this->FindSubPane("Show New"));
  118.     info.attr.showNew = control->GetValue();
  119.     
  120.     control = dynamic_cast<TControl*>(this->FindSubPane("Start on Preferred"));
  121.     info.attr.startOnPreferred = control->GetValue();
  122.     
  123.     control = dynamic_cast<TControl*>(this->FindSubPane("Erase on Update"));
  124.     info.attr.eraseOnUpdate = control->GetValue();
  125.     
  126.     swatch = dynamic_cast<TColorSwatch*>(this->FindSubPane("Color"));
  127.     info.attr.color = swatch->GetColor();
  128.     
  129.     return info;
  130. }
  131.  
  132.  
  133. //---------------------------------------------------------------
  134. //
  135. // CWindowDrawEditor::SetEditorInfo
  136. //
  137. //---------------------------------------------------------------
  138. void CWindowDrawEditor::SetEditorInfo(const SWindowInfo& info)
  139. {
  140.     TControl* control = nil;
  141.     TColorSwatch* swatch = nil;
  142.         
  143.     control = dynamic_cast<TControl*>(this->FindSubPane("Position"));
  144.     control->SetValue(info.attr.autoPosition);
  145.     
  146.     control = dynamic_cast<TControl*>(this->FindSubPane("Show New"));
  147.     control->SetValue(info.attr.showNew);
  148.     
  149.     control = dynamic_cast<TControl*>(this->FindSubPane("Start on Preferred"));
  150.     control->SetValue(info.attr.startOnPreferred);
  151.     
  152.     control = dynamic_cast<TControl*>(this->FindSubPane("Erase on Update"));
  153.     control->SetValue(info.attr.eraseOnUpdate);
  154.     
  155.     swatch = dynamic_cast<TColorSwatch*>(this->FindSubPane("Color"));
  156.     swatch->SetColor(info.attr.color);
  157. }
  158.  
  159.  
  160.